//
//  ChangePasswordViewController.m
//  tingche
//
//  Created by 尤振宇 on 2017/6/19.
//  Copyright © 2017年 尤振宇. All rights reserved.
//

#import "ChangePasswordViewController.h"
#import "ChangePasswordApi.h"

@interface ChangePasswordViewController ()
@property (weak, nonatomic) IBOutlet UITextField *password2;
@property (weak, nonatomic) IBOutlet UITextField *password3;
@end

@implementation ChangePasswordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)OKAction:(id)sender {
    if (![self.password2 hasText]) {
        [MBProgressHUD showError:@"请输入新密码"];
        return ;
    }
    if (![self.password3 hasText]) {
        [MBProgressHUD showError:@"请输入确认密码"];
        return ;
    }
    
    if (![self.password2.text isEqualToString:self.password3.text]) {
        [MBProgressHUD showError:@"确认密码有误"];
        return ;
    }
    
    ChangePasswordApi *api = [[ChangePasswordApi alloc]initWithPassword1:self.password2.text Password2:self.password3.text];
    [api startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
        if (kCode(request.responseJSONObject)) {
            [MBProgressHUD showSuccess:@"修改成功"];
            [self.navigationController popViewControllerAnimated:YES];
        }
    } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
        
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
